package com.iot.ammeter.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.iot.ammeter.R


/**
 * 充值记录 - 空数据展示
 */
@Composable
internal fun FillRecordNoData() = Column(
    horizontalAlignment = Alignment.CenterHorizontally,
    modifier = Modifier.fillMaxWidth()
) {
    Text(text = "- 无充值记录 -", style = MaterialTheme.typography.labelSmall)
}

/**
 * 充值记录 - 卡片
 */
@Composable
internal fun FillRecordCard(record: Array<String>) = Box(
    modifier = Modifier
        .padding(0.dp, 8.dp)
) {
    val colon = "："
    val subtitles = arrayOf(
        stringResource(id = R.string.balance_fill_time),
        stringResource(id = R.string.balance_fill_amount),
        stringResource(id = R.string.balance_fill_payment)
    )
    Column(
        modifier = Modifier
            .background(
                MaterialTheme.colorScheme.surfaceVariant.copy(.5F),
                RoundedCornerShape(10.dp),
            )
            .fillMaxWidth()
            .padding(15.dp, 10.dp)
    ) {
        for (index in subtitles.indices) {
            Row(modifier = Modifier.padding(0.dp, 3.dp)) {
                Text(
                    text = subtitles[index] + colon,
                    style = MaterialTheme.typography.labelLarge,
                    color = MaterialTheme.colorScheme.onSurfaceVariant
                )
                Text(
                    text = record[index],
                    style = MaterialTheme.typography.bodyMedium,
                    color = MaterialTheme.colorScheme.onSurfaceVariant
                )
            }
        }
    }
}
